package guoanmaker.operator.business.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import guoanmaker.operator.business.model.InRoundPhone;
import guoanmaker.operator.business.model.OperatorCommonServiceNew;
import guoanmaker.operator.business.service.OperatorCommonServiceNewServiceInterface;
import guoanmaker.operator.helper.common.AjaxJson;
import guoanmaker.operator.helper.common.abstractobj.ApiController;
import io.swagger.annotations.ApiOperation;

/**
 * 
    * @ClassName: OperatorCommonServiceNewController  
    * @Description: 运营后台PC首页控制常用服务配置接口  
    * @author lsy  
    * @date 2017年12月15日 上午11:11:50    
    *
 */
@RestController
@RequestMapping(ApiController.OPERATOR_COMMON_SERVICE_NEW)
public class OperatorCommonServiceNewController {
	@Autowired
	private OperatorCommonServiceNewServiceInterface operatorCommonServiceNewServiceInterface; 
	/**
	 * 
	    * @Title: saveOperatorCommonServiceNew  
	    * @Description: 常用服务配置  
	    * @param @param inRoundPhone
	    * @param @return      
	    * @return AjaxJson      
	    * @throws
	 */
	@ApiOperation(value = "常用服务配置", notes = "常用服务配置")
	@PostMapping("saveOperatorCommonServiceNew")
	public AjaxJson saveOperatorCommonServiceNew(@RequestBody InRoundPhone inRoundPhone) {
		AjaxJson ajaxJson=new AjaxJson();
		try {
			operatorCommonServiceNewServiceInterface.deleteOperatorCommonServiceNewRound(inRoundPhone);
			operatorCommonServiceNewServiceInterface.saveOperatorCommonServiceNew(inRoundPhone);
			ajaxJson.setSuccess(true).setStatus(200).setData(null).setMsg("操作成功");
		} catch (Exception e) {
			e.printStackTrace();
			ajaxJson.setSuccess(false).setStatus(500).setData(null).setMsg("操作失败");
		}
		return ajaxJson;
	}
	/**
	 * 
	    * @Title: selectAllOperatorCommonServiceNew  
	    * @Description: 传入城市id 查询所有服务配置 
	    * @param @param cityCode
	    * @return AjaxJson      
	    * @throws
	 */
	@ApiOperation(value = "查询所有服务配置", notes = "查询所有服务配置")
	@PostMapping("selectAllOperatorCommonServiceNew")
	public AjaxJson selectAllOperatorCommonServiceNew(String cityId) {
		AjaxJson ajaxJson=new AjaxJson();
		try {
			ajaxJson.setSuccess(true).setStatus(200).setData(operatorCommonServiceNewServiceInterface.selectAllOperatorCommonServiceNew(cityId)).setMsg("操作成功");
		} catch (Exception e) {
			ajaxJson.setSuccess(false).setStatus(500).setData(null).setMsg("操作失败");
		}
		
		return ajaxJson;
	}

}
